/*********************************************************************************
Organization 					: 				Georgia Institute of Technology
  
Institute 						:				Cognitive Computing Group(CCL)
 
Authors							: 				Manish Mehta 
 												
Class							:				GameStateEntry
 
Function						: 				A simple class for holding a game state 
												entry
****************************************************************************/
package trace;

import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;

import org.w3c.dom.Node;

import base.CBLILRModule;

public class GameStateEntry implements Serializable{
	private Double cycle;
	private transient Node gamestate;
	public GameStateEntry(double cycle, Node gamest)
	{
		cycle = new Double(cycle);
		gamestate = gamest;
	}
	// TODO use XMLWriter
	private void writeObject(java.io.ObjectOutputStream out) throws IOException, ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException
	{
		out.defaultWriteObject();
		String s = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <gamestate xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"Wargus-trace.xsd\">";
		s = s + CBLILRModule.GenerateXML(gamestate);
		s = s + "</gamestate>";
		out.writeObject(s);
		out.flush();
	}	
	private void readObject(java.io.ObjectInputStream in) throws IOException,
    ClassNotFoundException, ClassCastException, InstantiationException, IllegalAccessException
    {
		in.defaultReadObject();
		String str = (String)in.readObject();
		StringReader rd = new StringReader(str);
		gamestate = CBLILRModule.ReadXMLfromReader(rd).getFirstChild();
	}
	public void setCycle(double cycle)
	{
		cycle = new Double(cycle);
	}
	public void setGameState(Node gamest)
	{
		gamestate = gamest;
	}
	public Double getCycle()
	{
		return cycle;
	}
	public Node getGameState()
	{
		return gamestate;
	}
}
